<?php
/**
 * jishupu-cms
 * @Author:技术铺
 * @Date:2021/11/21
 */

namespace App\Filters\Example;

use App\Filters\BaseFilter;

/**
 * 普通表格演示模块过滤器
 *
 * Class ExampleTableFilter
 * @package App\Filters
 */
class ExampleTableFilter extends BaseFilter
{
    /**
     * 创建时间范围
     * @param $created_at
     * @return mixed
     */
    protected function createdAt($created_at = [])
    {
        if (!empty($created_at)) {
            return $this->builder->whereBetween('created_at', $created_at);
        }
    }

    /**
     * 推荐类型
     * @param $recommend_type
     * @return mixed
     */
    protected function recommendType($recommend_type = [])
    {
        if (!empty($recommend_type)) {
            return $this->builder->whereRaw('FIND_IN_SET(?,recommend_type)', $recommend_type);
        }
    }
}
